import time

from public.action import *
from public.business import *
from public.testData import *
from public.tools import *

testCase = "DBshop024"
firefox = openBrowser(url)
comment = '123'
# 1.登录前台界面，点击我的订单，已完成订单，点击尚未评价，编写商品评价“下次还是会回购”，点击“点击提交”按钮。
DBshopLogin(firefox,'yuqilin','123456')
firefox.find_element_by_link_text('我的订单').click()
firefox.find_element_by_partial_link_text('交易完成').click()
firefox.find_element_by_link_text('尚未评价').click()
firefox.find_element_by_id('comment_body').send_keys(comment)
firefox.find_element_by_xpath('//button[contains(text(),"点击提交")]').click()
# 2.回到后台界面，点击“编辑查看”，点击“删除”，确认删除，删除成功。
firefox.get(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu2(firefox,'商品管理','商品评价')
firefox.find_element_by_link_text('编辑查看').click()
firefox.find_element_by_xpath('//td[contains(.,"%s")]/following-sibling::td[4]/a[2]'%comment).click()
firefox.switch_to.alert.accept()
time.sleep(8)
try:
    firefox.find_element_by_xpath('//td[contains(.,"%s")]'%comment)
    writeLog("%s 测试失败"%testCase)
except:
    writeLog("%s 测试通过"%testCase)